﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Poney_fight_club
{
    public partial class Form_background : Form
    {
        //6."Champion de l'arène utilise Poney. Changer de poney ?"
        //Delete "//" for the next line
        private Arena myArena;

        public void DrawMeAPony()
        {
            //3. Dessine moi un poney !

            /*Pony my_first_pony = new Pony("warlock", 42, 18, PColor.Pink); //Instance de la classe Pony
            //Complete my_first_pony attributes here  
            //Use Presentation() to write pony presentation in "textBox_informations" here
            my_first_pony.Presentation(); //Utilisation de la methode Presentation avec l'objet my_first_pony
            Attack Mist = new Attack("Mist of Darkness", 5, 15, 5, 5);
            Attack Rhapsody = new Attack("Rhapsody of Fire", 1, 40, 10, 10);
            my_first_pony.SetAttack(Mist, 0);
            my_first_pony.SetAttack(Rhapsody, 1);*/
        }

        //6."Champion de l'arène utilise Poney. Changer de poney ?"
        //Delete "//" for the all InitPonies() method
        private Arena InitPonies()
        {
            Attack[] TabAttack1 = new Attack[2];
            Attack[] TabAttack2 = new Attack[2];

            TabAttack1[0] = new Attack("Mist of Darkness", 5, 15, 5, 5);
            TabAttack2[0] = new Attack("Slash", 5, 13, 3, 7);
            TabAttack1[1] = new Attack("Rhapsody of Fire", 1, 40, 1, 9);
            TabAttack2[1] = new Attack("Toxic", 5, 20, 2, 5);

            Arena myArena = new Arena(new Pony("warlock", 18, 142, PColor.Blue, TabAttack1), new Pony("Poney_right", 13, 50, PColor.Pink, TabAttack2));

            if (myArena.Poneyl.Color == PColor.Blue)
                pictureBox_left_pony.Load("../SRC/pony_blue_l.png");
            else if (myArena.Poneyl.Color == PColor.Yellow)
                pictureBox_left_pony.Load("../SRC/pony_yell_l.png");
            else
                pictureBox_left_pony.Load("../SRC/pony_pink_l.png");

            if (myArena.Poneyr.Color == PColor.Blue)
                pictureBox_right_pony.Load("../SRC/pony_blue_r.png");
            else if (myArena.Poneyr.Color == PColor.Yellow)
                pictureBox_right_pony.Load("../SRC/pony_yell_r.png");
            else
                pictureBox_right_pony.Load("../SRC/pony_pink_r.png");

            return myArena;
        }

        //6."Champion de l'arène utilise Poney. Changer de poney ?"
        //Delete "//" for the all UpdateDisplaying() method
        private void UpdateDisplaying()
        {
            if (myArena.Current_Pony == 1)
            {
                pictureBox_Current.Load("../SRC/current_left.png");
                label_fight_1.Text = myArena.Poneyl.GetAttack(1).Name;
                label_fight_2.Text = myArena.Poneyl.GetAttack(2).Name;
                textBox_informations.Text = myArena.Poneyl.Presentation();
            }
            else
            {
                pictureBox_Current.Load("../SRC/current_right.png");
                label_fight_1.Text = myArena.Poneyr.GetAttack(1).Name;
                label_fight_2.Text = myArena.Poneyr.GetAttack(2).Name;
                textBox_informations.Text = myArena.Poneyr.Presentation();
            }
            label_life_points_left_pony.Text = myArena.Poneyl.Pv.ToString();
            label_life_points_right_pony.Text = myArena.Poneyr.Pv.ToString();
        }

        //6."Champion de l'arène utilise Poney. Changer de poney ?"
        //Delete "//" for the all UpdateAttack() method
        private void UpdateAttack(int n)
        {
            //Here, in three lines: the current pony attack the other one, the current pony change and the displaying is updated.
            myArena.AttackWith(n);
            myArena.ChangeCurrentPony();
            UpdateDisplaying();

            if (myArena.IsFinish())
            {
                label_fight_1.Enabled = false;
                label_fight_2.Enabled = false;
                if (myArena.Current_Pony == 1)
                    label_life_points_left_pony.Text = "Game Over";
                else
                    label_life_points_right_pony.Text = "Game Over";
            }
        }

        public Form_background()
        {
            InitializeComponent();

            //3. Dessine moi un poney !
            // Put "//" before next line after section 3.
            DrawMeAPony();

            //6."Champion de l'arène utilise Poney. Changer de poney ?"
            //Delete "//" for the two next lines
            myArena = InitPonies();
            UpdateDisplaying();
        }

        private void label_run_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void label_fight_1_Click(object sender, EventArgs e)
        {
            //6."Champion de l'arène utilise Poney. Changer de poney ?"
            //Delete "//"
            UpdateAttack(1);
        }

        private void label_fight_2_Click(object sender, EventArgs e)
        {
            //6."Champion de l'arène utilise Poney. Changer de poney ?"
            //Delete "//"
            UpdateAttack(2);
        }
    }
}
